package cn.com.dycc.meeting_assist.meeting_sign.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.dycc.common.controller.BaseController;
import cn.com.dycc.meeting_assist.meeting_sign.entity.Sign;
import cn.com.dycc.meeting_assist.meeting_sign.param.FindSignParam;
import cn.com.dycc.meeting_assist.meeting_sign.service.SignNotFoundException;
import cn.com.dycc.meeting_assist.meeting_sign.service.SignService;
import cn.com.dycc.util.JsonObjectResult;


/**
 * 
 * Description: 会议签到管理控制层
 * Author: Liket
 * Version: 1.0
 * Create Date Time: 2018年10月29日 下午3:54:20.
 * Update Date Time: 
 * @see
 */
@Controller
@RequestMapping("/sign")
public class SignController extends BaseController{
	
	@Resource
	private SignService signService;
	
	@RequestMapping("/add.do")
	@ResponseBody
	public JsonObjectResult addSign(HttpServletRequest req,Sign sign){
		int n = signService.addSign(req, sign);
		return new JsonObjectResult(n);
	}
	
	/*@RequestMapping("/delete.do")
	@ResponseBody
	public JsonObjectResult deleteSign(HttpServletRequest req,Sign sign){
		int n = signService.deleteSign(req, sign);
		return new JsonObjectResult(n);
	}*/
	
		
	@RequestMapping("/find.do")
	@ResponseBody
	public JsonObjectResult findSign(HttpServletRequest req,FindSignParam param){
		Sign sign = signService.findSignById(req, param);
		return new JsonObjectResult(sign);
	}
	
	@RequestMapping("/param.do")
	@ResponseBody
	public JsonObjectResult paramSign(HttpServletRequest req,FindSignParam param){
		List<Sign> list = signService.findSignByParam(req, param);
		String count = signService.countSignByParam(req, param);
		return new JsonObjectResult(count,list);
	}
	
	@ExceptionHandler(SignNotFoundException.class)
	@ResponseBody
	public JsonObjectResult signException(SignNotFoundException e){
		e.printStackTrace();
		return new JsonObjectResult(1012,e);
	}
}
